#ifndef SQLMANAGE
#define SQLMANAGE

#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlError>
#include <QtSql/QSqlDriver>
#include <QtDebug>
#include <QtSql/QSqlRecord>
#include <errno.h>
//#include <unistd.h>
class SqlManage
{
public:
    static const int perPageNum = 15;

    SqlManage();
    QSqlQuery queryTable(QString tabeName, QString field="", QString keyWord="");
    QSqlQuery querySort(QString tableName, QString field);
    QSqlQuery queryGetPage(QString tableName, int page, QString sortField = "");
    int getTotalPage(QString tableName);
    bool exec(QString query);
    void closeSql();
    bool addItem(QString command);
    bool delItemById(QString tableName, QString key, long long id);
    bool editItemById(QString command);

private:
    QSqlDatabase db;
    int pageMax = -1;
};

#endif // SQLMANAGE

